<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/**
 * 门店模型
 */
class Store extends Model
{
    use HasFactory;
    protected $guarded=[];
    public function comments()
    {
        return $this->hasMany(StoreComment::class);
    }
    //查看门店
    static function lookStores(){
        return self::where(['is_del'=>0])->get()->toArray();
    }


    //查看所有门店
    static function getStores(){
        return self::where('is_del','0')->get();
    }

    //搜索详情门店
    static function selectStores($where){
        return self::where($where)->where('is_del','0')->get();
    }

    //添加门店
    static function addStore(array $param){
        return self::create($param);
    }

    //更新门店
    static function updateStore(int $id,array $param){
        return self::where('id',$id)->update($param);
    }

    //删除门店
    static function removeStore(int $id){
        return self::where('id',$id)->update(['is_del'=>1]);
        //dd($id);
    }
}
